﻿/*
ParallelPlatform Project - A web platform to distribute and share knowledge
Online Editor - An online tool to create and play animations
Copyright (C) 2011 Daniel Guerrero Martínez & Sergio Rodríguez Lumley

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package Classes{
	import flash.display.MovieClip;
//	import flash.utils.getDefinitionByName;
	import flash.events.Event;
	public class DarkPanel extends Panel {
		
		private var revealMe:Boolean;
		
		public function DarkPanel(){
			revealMe = false;
			alpha = 0;
		}
		
		public function beginShow():void{
			revealMe = true;
			this.addEventListener(Event.ENTER_FRAME, refreshShow);
		}
		
		public function endShow():void{
			revealMe = false;
			this.addEventListener(Event.ENTER_FRAME, refreshShow);
		}
		
		private function refreshShow(evt:Event):void{
			if(revealMe){
				alpha = Math.min(1, alpha+0.05);
				if(alpha == 1)
					this.removeEventListener(Event.ENTER_FRAME, refreshShow);
			}else{
				alpha = Math.max(0, alpha-0.05);
				if(alpha == 0){
					this.removeEventListener(Event.ENTER_FRAME, refreshShow);
					if(parent != null) parent.removeChild(this);
				}
			}
		}
	}
}